package com.icemelon.catdog.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.icemelon.catdog.dao.AffairMapper;
import com.icemelon.catdog.pojo.Affair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
@Service
public class UserAffairServiceImpl implements UserAffairService {
    @Autowired
    private AffairMapper affairMapper;


    @Override
    public void uploadAffair(Affair affair) {
        affairMapper.insert(affair);

    }

    @Override
    public List<Affair> getAffair(Integer[] ids) {
        List<Integer> list= Arrays.asList(ids);
        return affairMapper.selectBatchIds(list);

    }

    @Override
    public void deleteAffair(Integer[] ids) {
        List<Integer> list= Arrays.asList(ids);
        affairMapper.deleteBatchIds(list);
    }

    @Override
    public List<Affair> getAllAffair(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(id!=null && id>=0,"id",id);
        List<Affair> affairList = affairMapper.selectList(queryWrapper);
        return affairList;
    }
}
